package com.bilin.coin.network.callback;


import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

import io.reactivex.Observer;
import io.reactivex.annotations.NonNull;
import io.reactivex.disposables.Disposable;
import okhttp3.ResponseBody;

/**
 * Created by LG on 2018/4/15.
 */

public abstract class BitmapCallBack<T extends Bitmap> implements Observer<ResponseBody>{

    @Override
    public void onSubscribe(@NonNull Disposable d) {

    }

    @Override
    public void onNext(@NonNull ResponseBody responseBody) {
        onCallBackNext(BitmapFactory.decodeStream(responseBody.byteStream()));
    }

    @Override
    public void onError(@NonNull Throwable e) {
        onCallBackError(e);
    }

    @Override
    public void onComplete() {

    }

    public abstract void onCallBackNext(Bitmap result);

    public abstract void onCallBackError(Throwable e);

}
